package org.redhat.auth.security.taglibs;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.components.UIBean;
import org.redhat.auth.security.util.AuthUserUtil;

import com.opensymphony.xwork2.util.ValueStack;

public class TagUser extends UIBean {

	private String property;

	@Override
	public String getTheme() {
		return "auth";
	}

	public TagUser(ValueStack stack, HttpServletRequest request,
			HttpServletResponse response) {
		super(stack, request, response);
	}

	@Override
	protected String getDefaultTemplate() {
		return "auth_user";
	}

	public String getProperty() {
		return property;
	}

	public void setProperty(String property) {
		this.property = property;
	}

	@Override
	protected void evaluateExtraParams() {
		super.evaluateExtraParams();
		Object value = AuthUserUtil.getUserProperty(property);
		if (value == null)
			return;
		addParameter("value", value);
	}
}
